package crossover;

import java.util.ArrayList;
import java.util.List;

import neural.Individual;

import util.RandomUtils;

public class ClassicCrossover extends AbstractCrossover {


	public List<Individual> generateChilds(Individual father2, Individual mother2) {
		List<Double> father = father2.getWeights();
		List<Double> mother = mother2.getWeights();
		int locus = RandomUtils.randomBetween(0, father.size()) ; //rand positiopn of pather lenght
		List<Double> son1 = new ArrayList<Double>();
		List<Double> son2 = new ArrayList<Double>();
		
		son1.addAll(father.subList(0, locus));
		son2.addAll(mother.subList(0, locus));
//		System.out.println("father size = " + father.size());
//		System.out.println("mother size = " + mother.size());
		son1.addAll(mother.subList(locus, father.size()));
		son2.addAll(father.subList(locus, father.size()));
//		System.out.println("hijo1" + son1);
//		System.out.println("hijo2" + son2);
		List<Individual> resp = new ArrayList<Individual>();
		resp.add(new Individual(son1));
		resp.add(new Individual(son2));
		return resp;
	}
}
